const Controller = require('egg').Controller

class UserController extends Controller {

  async index() {
    const {ctx} = this
    let res = await ctx.service.user.getUserList()
    ctx.body = {
      code:20000,
      data:res
    }
  }

  async update() {
    const {ctx} = this
    const id = ctx.params.id
    const status = ctx.request.body.data
    let res = await ctx.service.user.updateStatus(id,status)
    if(res) {
      ctx.body = {
        code: 20000,
        data:'yes'
      }
    }else {
      ctx.body = {
        code: 50000,
        data:'服务器异常'
      }
    }
  }

}

module.exports = UserController